﻿@{
    ViewBag.Title = "Test1";
    Layout = "~/Views/Shared/_LayoutForTest.cshtml";
}

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',title:'北部'" style="height:300px;">

        Value：<input type="text" id="ID" />
        <br /><br />
        Text：<textarea id="Name" rows="3" cols="3" style="width:500px;"></textarea>
        <input type="button" id="select" value="选择" />
        <input type="button" id="clear" value="清空" />
        <br /><br /><br /><br /><br />

    </div>
    <div id="west" data-options="region:'west',title:'西部'" style="width:300px;">
        @*<div id="aa" class="easyui-accordion" style="width:300px;height:200px;">
                <div title="Title1" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
                    <h3 style="color:#0099FF;">Accordion for jQuery</h3>
                    <p>
                        Accordion is a part of easyui framework for jQuery.
                        It lets you define your accordion component on web page more easily.
                    </p>
                </div>
                <div title="Title2" data-options="iconCls:'icon-reload',selected:true" style="padding:10px;">
                    content2
                </div>
                <div title="Title3">
                    content3
                </div>
            </div>*@
    </div>
    <div id="cen" data-options="region:'center',title:'中部'">
        <img src="../../../../../favicon.ico" />
    </div>
</div>

<script>
    $(function () {

        $("#select").click(function () {
            var selected = $("#ID").val();
            var onEnterClick = function (selections) {
                if (selections.length > 0) {
                    $("#ID").val($.array.map(selections, function (item) { return item.ID; }));
                    $("#Name").val($.array.map(selections, function (item) { return item.RealName; }));
                } else {
                    $.easyui.messager.alert("提示", "请先选择一行", "warning");
                    return false;
                }
            };
            var onEnterClick1 = function (selected) {
                if (selected) {
                    $("#ID").val(selected.ID);
                    $("#Name").val(selected.RealName);
                } else {
                    $.easyui.messager.alert("提示", "请先选择一行", "warning");
                    return false;
                }
            };
            var onEnterClick2 = function (selected) {
                if (selected) {
                    $("#ID").val(selected.id);
                    $("#Name").val(selected.text);
                } else {
                    $.easyui.messager.alert("提示", "请先选择一行", "warning");
                    return false;
                }
            };

            $.seven.test.showAccordionDblDataGridSelector(onEnterClick, selected, 2, true);

        });

        $("#clear").click(function () {
            $("#ID").val('');
            $("#Name").val('');
        });


        var _initAccordion = function () {
            var panelWest = $("#west");
            var accordion = $("<div />").appendTo(panelWest);

            //$("<div />").attr({ title:"测试1" }).html("文本1").appendTo(accordion);
            //$("<div />").attr({ title:"测试2" }).html("文本2").appendTo(accordion);

            accordion.accordion({ fit: true, animate: true });

            accordion.accordion("add", { title: "测试标题", content: "测试" });

            var flag = false;
            var testset = function () {
                var panel = accordion.accordion("getSelected");
                if (panel) {
                    flag = true;
                    var opts = panel.panel("options");
                    console.warn(opts.content);
                }
                else {
                    console.warn("123");
                }
                if (!flag)
                {
                    $.util.exec(testset, 100);
                }
                //以上代码说明，accordion在执行add之后，panel并不是马上被渲染完成的。
            };
            $.util.exec(testset);
        };

        _initAccordion();
    });
</script>
